package com.chatplus.application.web;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 验证码 自动配置。
 */
@EnableConfigurationProperties
@Configuration
public class VerificationConfig {
    public static final String PREFIX_VERIFICATION_CONFIG = "chatplus.verification";
    public static final String PREFIX_SMS_CAPTCHA_CONFIG = PREFIX_VERIFICATION_CONFIG + ".captcha.sms";
    public static final String PREFIX_MAIL_CAPTCHA_CONFIG = PREFIX_VERIFICATION_CONFIG + ".captcha.mail";

    @Bean
    @ConfigurationProperties(PREFIX_SMS_CAPTCHA_CONFIG)
    public SmsCaptchaProperties smsCaptchaProperties() {
        return new SmsCaptchaProperties();
    }

    @Bean
    @ConfigurationProperties(PREFIX_MAIL_CAPTCHA_CONFIG)
    public MailCaptchaProperties mailCaptchaProperties() {
        return new MailCaptchaProperties();
    }

    public static class SmsCaptchaProperties {
        private Boolean enabledMock;

        public Boolean getEnabledMock() {
            return enabledMock;
        }

        public void setEnabledMock(Boolean enabledMock) {
            this.enabledMock = enabledMock;
        }
    }

    public static class MailCaptchaProperties {
        private Boolean enabledMock;

        public Boolean getEnabledMock() {
            return enabledMock;
        }

        public void setEnabledMock(Boolean enabledMock) {
            this.enabledMock = enabledMock;
        }
    }
}
